home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ov143b.zip / OVSTR.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  2KB  |  64 lines

  1. /*  002  20-Apr-87  ovstr.c
  2.  
  3.         Some OV specific string routines.
  4.  
  5.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  6. */
  7.  
  8. #include "ov.h"
  9.  
  10.  
  11. /*****************************************************************************
  12.                              M U S T A L L O C
  13.  *****************************************************************************/
  14.  
  15. char * ALTCALL
  16. mustalloc(len)         /* allocate memory or die */
  17. int len;
  18. {
  19.    char *mp;
  20.  
  21.    if (mp = (char *) malloc(len))      /* try to allocate, return addr if ok */
  22.       return(mp);
  23.  
  24.    /* Can't allocate, time to die! The following routines better not call us! */
  25.  
  26.    reset_tty();
  27.    putstr("\r\nOverView ran out of memory!\r\n");
  28.    exit();
  29. }
  30.  
  31.  
  32. /*****************************************************************************
  33.                              M U S T D U P
  34.  *****************************************************************************/
  35.  
  36. char * ALTCALL
  37. mustdup(sp)    /* duplicate a string or die */
  38. char *sp;
  39. {
  40.    char *nsp;
  41.  
  42.    nsp = mustalloc(strlen(sp)+1);
  43.    strcpy(nsp,sp);
  44.    return(nsp);
  45. }
  46.  
  47.  
  48. /*****************************************************************************
  49.                            M U S T N D U P
  50.  *****************************************************************************/
  51.  
  52. char * ALTCALL
  53. mustndup(sp,n)         /* duplicate part of a string or die! */
  54. char *sp;
  55. int n;
  56. {
  57.    char *nsp;
  58.  
  59.    nsp = mustalloc(n+1);
  60.    *nsp = '\0';
  61.    strncat(nsp,sp,n);
  62.    return(nsp);
  63. }
  64.